/*
* 用户有关访问接口数据
*/
import { setCommonSystemLoading, setCommonDate } from './Action';
import * as DataName from './DataNameConfig';
import { CASH_API_TYPE } from "../utils/Api";
import Util from '../utils/Util';
import HttpServer from '../axios';
import { message } from 'antd';

/**
 * 提现列表
 * @param {Object} filter
 */
export const GetCashList =(filter)=> {
    return dispatch=>{
        HttpServer(Util.getApi(CASH_API_TYPE,"CashList"),filter)
            .then((res)=>{
                dispatch(setCommonSystemLoading(DataName.BASE_CARD_LOADING,false));
                dispatch(setCommonSystemLoading(DataName.BASE_TABLE_LOADING,false));
                res.result.filter = filter;
                dispatch(setCommonDate('set_base_data',DataName.CASH_LIST,res.result))
            },(error)=>{
                dispatch(setCommonSystemLoading(DataName.BASE_TABLE_LOADING,false));
                console.log(error)
            })
    }
}

/**
 * 更新提现信息
 * @param {Object} filter
 * @param {Object} fil
 */
export const UpdateCash =(filter,fil)=> {
    return dispatch=>{
        let obj = {...Util.getApi(CASH_API_TYPE,"UpdateCash")};
        obj.url += filter.cid+"/yesd/"+filter.status;
        HttpServer(obj,filter)
            .then((res)=>{
                if(res.result){
                    message.success("更新成功");
                    dispatch(setCommonSystemLoading(DataName.BASE_TABLE_LOADING,true));
                    dispatch(GetCashList({...fil}));
                }else{
                    message.error(res.serror.desc);
                }

            },(error)=>{
                dispatch(setCommonSystemLoading(DataName.BASE_TABLE_LOADING,false));
                console.log(error)
            })
    }
}

